package com.jyb.qiyefuwu.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;


import com.jyb.qiyefuwu.R;
import com.jyb.qiyefuwu.databinding.DialogServiceOderNodeBinding;
import com.jyb.qiyefuwu.entity.ServiceNodeBean;
import com.jyb.qiyefuwu.view.adpater.ServiceOderNodeAdapter;

import org.jetbrains.annotations.NotNull;

import java.util.List;


/**
 * @author: 陈方凯
 * @date: 2021/09/27
 * @Description: 服务订单详情 dialog
 */
public class OderNodeDialog extends Dialog implements View.OnClickListener {
    private DialogServiceOderNodeBinding mBinding;
    private List<ServiceNodeBean> list;
    private ServiceOderNodeAdapter mAdapter;
    private Context mContext;

    public OderNodeDialog(@NonNull @NotNull Context context, List<ServiceNodeBean> list) {
        super(context, R.style.RoundCornerDialog);
        mBinding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.dialog_service_oder_node, null, false);
        setContentView(mBinding.getRoot());
        mContext = context;
        this.list = list;
        init();
        Window window = getWindow();
        if (window != null) {
            WindowManager.LayoutParams params = window.getAttributes();
            params.gravity = Gravity.CENTER;
            window.setAttributes(params);
        }
    }

    private void init() {
        mAdapter = new ServiceOderNodeAdapter(mContext, list);
        mAdapter.setItemSelect(false);
        mBinding.nodeListMax.setLayoutManager(new LinearLayoutManager(mContext));
        mBinding.nodeListMax.setAdapter(mAdapter);
        mBinding.closeView.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.close_view) {
            dismiss();
        }

    }

}
